package com.allqj.sfx.infrastructure.vo;

import com.allqj.sfx.infrastructure.enums.ResultStatusCodeEnum;

import java.io.Serializable;

/**
 * @author sjw
 * @className ResultVO
 * @date 2022/7/19 9:01
 * @description: 返回值统一格式
 */
public class ResultVO<T> implements Serializable {
    private T result;
    private Integer statusCode;
    private String message;

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    public Integer getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(Integer statusCode) {
        this.statusCode = statusCode;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static <T> ResultVO<T> Instance(T result) {
        return Instance(ResultStatusCodeEnum.OK.getCode(), ResultStatusCodeEnum.OK.getMessage(), result);
    }

    public static <T> ResultVO<T> Instance(Integer statusCode, String message) {
        return Instance(statusCode, message, null);
    }

    public static <T> ResultVO<T> Instance(Integer statusCode, String message, T result) {
        ResultVO<T> resultVO = new ResultVO<T>();
        resultVO.setStatusCode(statusCode);
        resultVO.setMessage(message);
        resultVO.setResult(result);
        return resultVO;
    }
}
